package com.hao.gaoji;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

// 回顾
public class ThreadNew {
    public static void main(String[] args) {
        MyThread1 thread1 = new MyThread1();
        thread1.start();
        MyThread2 thread2 = new MyThread2();
        new Thread(thread2).start();
        MyThread3 thread3 = new MyThread3();
        FutureTask<String> futureTask = new FutureTask<String>(thread3);
        new Thread(futureTask).start();
        try {
            String result = futureTask.get();
            System.out.println(result);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
// 1、继承Thread类
class MyThread1 extends Thread{
    @Override
    public void run() {
        System.out.println("MyThread1------>Thread");
    }
}
// 2、实现Runnable接口
class MyThread2 implements Runnable{
    @Override
    public void run() {
        System.out.println("MyThread2------>Runnable");
    }
}
// 3、 实现Callable接口
class MyThread3 implements Callable<String>{
    @Override
    public String call() throws Exception {
        System.out.println("MyThread3------>Callable");
        return "Hello";
    }
}


